package com.cjm.algorithm.backtracking;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Ti46 {
    public static void main(String[] args) {
        Ti46 ti46 = new Ti46();
        List<List<Integer>> permute = ti46.permute(new int[]{1, 2, 3});
        System.err.println("OK");
    }

    List<List<Integer>> res = new ArrayList<>();
    LinkedList<Integer> path = new LinkedList<>();
    public List<List<Integer>> permute(int[] nums) {
        boolean[] dup = new boolean[nums.length];
        method46(nums, dup);
        return null;
    }

    private void method46(int[] nums, boolean[] dup) {
        if (path.size() == nums.length) {
            res.add(new ArrayList<>(path));
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            int cur = nums[i];
            if (dup[i]) {
                continue;
            }
            path.addLast(cur);
            dup[i] = true;
            method46(nums, dup);
            dup[i] = false;
            path.removeLast();
        }
    }
}
